﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include"unordered_map.h"
#include"unordered_set.h"

struct hashPair
{
	size_t operator()(const pair<int, int>& p)
	{
		return (p.first + p.second) * 13;
	}
};

void test_set()
{
	//unordered_set<int> s;
	//s.insert(2);
	//s.insert(3);
	//s.insert(5);
	//s.insert(7);
	//s.insert(4);
	//s.insert(9);
	//unordered_set<int>::iterator it = s.begin();

	//unordered_set<string> s;
	//s.insert("hh");
	//s.insert("xz");
	//s.insert("aa");
	//s.insert("33");
	//s.insert("您好");
	//unordered_set<string>::iterator it = s.begin();

	unordered_set<pair<int,int>, hashPair> s;
	s.insert(make_pair(3, 3));
	s.insert(make_pair(2, 2));
	s.insert(make_pair(5, 5));
	s.insert(make_pair(9, 9));
	s.insert(make_pair(20, 20));
	//unordered_set<pair<int, int>, hashPair>::iterator it = s.begin();
	auto it = s.begin();
	while (it != s.end())
	{
		//cout << *it << endl;
		cout << (*it).first << " " << (*it).second << endl;
		it++;
	}
	//for (auto e : s)
	//{
	//	printf("%s ", e.c_str());
	//}
}
void test_map()
{
	//unordered_map<string, string> dict;
	//dict.insert(make_pair("sort", ""));
	//dict.insert(make_pair("left", ""));
	//dict.insert(make_pair("left", "hh"));
	//dict["string"];
	//dict["left"] = "hh";
	//dict["string"] = "ll";

	unordered_map<int, string> m;
	m.insert(make_pair(1, "qq"));
	m.insert(make_pair(3, "tx"));
	m.insert(make_pair(2, "vx"));
	m.insert(make_pair(4, "ali"));

	unordered_map<int, string>::iterator it = m.begin();
	while (it != m.end())
	{
		cout << it->first << " " << it->second << endl;
		++it;
	}
	cout << endl;

	for (auto& kv : m)
	{
		cout << kv.first << " " << kv.second << endl;
	}



}
int main()
{
	//test_set();
	//test_map();
	return 0;
}